import 'package:flutter/material.dart';

/*
 * 设置button边界形状
 */

//set button border style
enum BorderType {
  CircleBorderType,
  StadiumBorderType,
}

class DKShapeOption {
  BorderType   sideBorderType;
  BorderStyle  borderStyle;
  Color        borderColor;
  DKShapeOption(this.sideBorderType,this.borderStyle,this.borderColor);
}

class DKButtonOption {

  Key key;
  VoidCallback onPressed;
  ValueChanged<bool> onHighlightChanged;
  ButtonTextTheme textTheme;
  Color textColor;
  Color disabledTextColor;
  Color color;
  Color disabledColor;
  Color focusColor;
  Color hoverColor;
  Color highlightColor;
  Color splashColor;
  Brightness colorBrightness;
  double elevation;
  double focusElevation;
  double hoverElevation;
  double highlightElevation;
  double disabledElevation;
  EdgeInsetsGeometry padding;
  ShapeBorder shape;
  Clip clipBehavior;
  FocusNode focusNode;
  MaterialTapTargetSize materialTapTargetSize;
  Duration animationDuration;
  Widget child;
  DKShapeOption shapeOption;

  DKButtonOption({
    Key key,
    this.onPressed, this.onHighlightChanged, this.textTheme, this.textColor, this.disabledTextColor,
    this.color, this.disabledColor, this.focusColor, this.hoverColor, this.highlightColor, this.splashColor, this.colorBrightness,
    this.elevation, this.focusElevation, this.hoverElevation, this.highlightElevation, this.disabledElevation, this.padding,
    this.clipBehavior, this.focusNode, this.materialTapTargetSize, this.animationDuration, this.child,
    this.shapeOption
  }) {
    clipBehavior ??= Clip.none;
    shapeOption ??= null;
    if(shapeOption!= null){
      switch(shapeOption.sideBorderType) {
        case BorderType.StadiumBorderType:
          shape = StadiumBorder(
              side:  BorderSide(
                style: shapeOption.borderStyle,
                color: shapeOption.borderColor,
              ));
          break;
        case BorderType.CircleBorderType:

          shape = CircleBorder(
              side:  BorderSide(
                style: shapeOption.borderStyle,
                color: shapeOption.borderColor,
              ));
          break;
      }
    }
  }
}

class DKButton extends RaisedButton {

  DKButton(DKButtonOption option) : super(
    key: option?.key,
    onPressed: option?.onPressed,
    onHighlightChanged: option?.onHighlightChanged,
    textTheme: option?.textTheme,
    textColor: option?.textColor,
    disabledTextColor: option?.disabledTextColor,
    color: option?.color,
    disabledColor: option?.disabledColor,
    focusColor: option?.focusColor,
    hoverColor: option?.hoverColor,
    highlightColor: option?.highlightColor,
    splashColor: option?.splashColor,
    colorBrightness: option?.colorBrightness,
    elevation: option?.elevation,
    focusElevation: option?.focusElevation,
    hoverElevation: option?.hoverElevation,
    highlightElevation: option?.highlightElevation,
    disabledElevation: option?.disabledElevation,
    padding: option?.padding,
    clipBehavior: option?.clipBehavior,
    shape: option?.shape,
    focusNode: option?.focusNode,
    materialTapTargetSize: option?.materialTapTargetSize,
    animationDuration: option?.animationDuration,
    child: option?.child,
  );
}




